package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	// 乘客关注司机表 或者司机关注乘客
	type UserFollow struct {
		models.BaseModel

		UserId   uint64 `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`         //关注者ID
		FollowId uint64 `gorm:"column:follow_id" db:"follow_id" json:"follow_id" form:"follow_id"` //被关注者ID
		Type     uint8  `gorm:"column:type;comment:1乘客关注司机 2司机关注乘客;" db:"type" json:"type" from:"type"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&UserFollow{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&UserFollow{})
	}

	migrate.Add("2023_07_18_145544_add_user_follows_table", up, down)
}
